package com.crr.mall.common.utils;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.crr.mall.common.bean.PageQuery;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

public abstract class MyBaseServiceImpl< M extends MyBaseMapper,T> extends ServiceImpl implements MyBaseService<T> {

    @Autowired
    protected M baseMapper;
    @Override
    public  PageUtils query(Map map) {
        int page = Integer.parseInt(map.get("page").toString());
        int pageSize = Integer.parseInt(map.get("pageSize").toString());
        PageHelper.startPage(page, pageSize);
        List<Map> list = baseMapper.query(map);
        PageInfo info = new PageInfo(list);
        return new PageUtils(list, (int) info.getTotal(), pageSize, page);
    }

}